﻿using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace Iptv.DownResourceItem.Model
{
    /// <summary>
    /// ftp参数
    /// </summary>
    [DisplayName("站点操作参数")]
    public class FtpUrlParameters : SiteConfig1
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="url"></param>
        public FtpUrlParameters(string url)
        {
            ID = Guid.NewGuid().ToString("N");
            Url = url;
            IP = string.Empty;
            Port = 21;
            UserId = "anonymous";
            Password = "anonymous@anonymous.net";
            Site = string.Empty;
        }
        /// <summary>
        /// 文件名
        /// </summary>
        public string FileName { get; set; }
        /// <summary>
        /// 文件名后缀
        /// </summary>
        public string FileExtName { get; set; }
        /// <summary>
        /// 文件类型 0 压缩包 1 视频 2 流文件 3 图片 4 XML 5 未知
        /// </summary>
        public int FileType
        {
            get
            {
                int tmpType = 5;
                if (!string.IsNullOrEmpty(FileExtName))
                {
                    tmpType = FileExtName.ToLower().IndexOf("tar") > 0 || FileExtName.ToLower().IndexOf("zip") > 0 ? 0 : tmpType;
                    tmpType = FileExtName.ToLower().IndexOf("mp4") > 0 || FileExtName.ToLower().IndexOf("ts") > 0 ? 1 : tmpType;
                    tmpType = FileExtName.ToLower().IndexOf("m3u8") > 0 ? 2 : tmpType;
                    tmpType = FileExtName.ToLower().IndexOf("png") > 0 || FileExtName.ToLower().IndexOf("jpg") > 0 ? 3 : tmpType;
                    tmpType = FileExtName.ToLower().IndexOf("xml") > 0 ? 4 : tmpType;
                }
                return tmpType;
            }
        }
        /// <summary>
        /// 文件相对路径 不包含站点信息 20240511/n41009qwd1q/321004/123.mp4
        /// </summary>
        public string FileSubName { get; set; }
        /// <summary>
        /// 远端文件路径
        /// </summary>
        /// <remarks>20240511/n41009qwd1q/321004 不包含站点和文件名</remarks>
        public string RemotePath { get; set; }
        /// <summary>
        /// 格式限制
        /// </summary>
        public string[] FileFormats { get; set; }
        /// <summary>
        /// 采集优先级
        /// </summary>
        [DisplayName("采集优先级")]
        public int Priority { get; set; } = 10;
        
        /// <summary>
        /// 待下载文件集合
        /// </summary>
        public List<FileSiteStruct> FileSets { get; set; }
        /// <summary>
        /// 操作类型 0 上传 1 下载 2 查询 3 删除
        /// </summary>
        [DisplayName("操作类型")]
        public EnumFtpAction Action { get; set; }
    }
}
